package flyshoes.config;


import flyshoes.interceptors.UserInfoInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@ConditionalOnClass(DispatcherServlet.class)//排除不存在mvc的类，此配置只会在存在该类的路径下生效
//DispatcherServlet是springMVC的核心组件之一
@RequiredArgsConstructor
public class MvcConfig implements WebMvcConfigurer {
    private final UserInfoInterceptor userInfoInter;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInfoInter);//无排除拦截路径
    }
}